//
//  ThirdViewController.m
//  电影豆瓣--完整版
//
//  Created by dllo on 15/12/31.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "ThirdViewController.h"
#import "cinemaTableViewCell.h"
#import "CinemaModel.h"
@interface ThirdViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSMutableArray *modelArr;

@end

@implementation ThirdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"影院";
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 69) style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    [_tableView release];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    // 注册重用池
    [_tableView registerClass:[cinemaTableViewCell class] forCellReuseIdentifier:@"cell"];
    
    [self dataHandle];
 
    
}
// 数据处理
- (void)dataHandle {
    self.modelArr = [NSMutableArray array];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"cinema" ofType:@"plist"];
    NSArray *tempArr = [NSArray arrayWithContentsOfFile:path];
    NSLog(@"%@", tempArr);
    for (NSDictionary *dic in tempArr) {
        CinemaModel *model = [CinemaModel cinemaModel];
        [model setValuesForKeysWithDictionary:dic];
        [_modelArr addObject:model];
        NSLog(@"%@", model);
    }

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _modelArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    cinemaTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    CinemaModel *model = _modelArr[indexPath.row];
    cell.imagView.image = [UIImage imageNamed:@"www.png"];
    cell.addressLabel.text = model.address;
    cell.titleLabel.text = model.cinemaName;
    cell.phoneLabel.text = model.telephone;
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 200;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
